<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fns" uri="http://java.sun.com/jsp/jstl/functionss" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <title>分区列表</title>
    <jsp:include page="../../body/link-page.jsp" flush="true"/>
    <style type="text/css">
        .layui-upload-drag {
            width:320px;
            height:160px;
            margin-left: 30px;
            border: 1px dashed #e2e2e2;
            background-color: rgba(204, 204, 204, 0.1);
            text-align: center;
            cursor: pointer;
            color: #999
        }

        .layui-upload-drag .layui-icon {
            margin-top: 40px;
            font-size: 68px;
            color: #999
        }
    </style>
</head>
<body>
<div class="panel">
    <form id="form" action="/car/parkingZone/list" method="post">
    <div class="panel-heading">
        <button type="button" id="demo-dt-addrow-btn" class="btn btn-info" onclick="LAYER.addLayerWithSize('layer_parkingZoneAdd','添加分区','/car/parkingZone/add','800px','520px')">
            <i class="fa fa-plus"></i> 添加
        </button>
        <button type="button" class="btn btn-success" onclick="toEdit();"><i class="fa fa-edit"></i>修改</button>
        <button type="button" class="btn btn-primary" onclick="deleteAll();"><i class="fa fa-trash-o"></i>删除</button>
    </div>

        <div class="panel-body" id="table-box">
            <table id="table" class="table table-striped table-bordered dataTable no-footer dtr-inline"
                   cellspacing="0" width="100%" role="grid" aria-describedby="demo-dt-addrow_info"
                   style="width: 100%;"
                   data-pn="${parkingZoneList.pageNum}" data-ps="${parkingZoneList.pageSize}" data-tp="${parkingZoneList.totalPage}"
                   data-tr="${parkingZoneList.totalRecord}">
                <thead>
                <tr role="row">
                    <th style="width: 20px;"><input type="checkbox" id="check-all"/></th>
                    <th>名称</th>
                    <th>停车场名称</th>
                    <th>层数</th>
                    <th>分区地图</th>
                    <th>分区车位地图</th>
                    <th>备注</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach var="parkingZone" items="${parkingZoneList.results}" varStatus="status">
                    <tr role="row" class="odd">
                        <td><input type="checkbox" value="${parkingZone.id}"/></td>
                        <td>${parkingZone.name}</td>
                        <td>${parkingZone.parkingName}</td>
                        <td>
                            <c:set var="floor" value="${parkingZone.floor}层"/>
                            ${parkingZone.floor == null ?parkingZone.floor:floor}
                        </td>
                        <td><img src="${parkingZone.zoneUrl}" style="height: 160px;max-width: 320px;"/></td>
                        <td><img src="${parkingZone.lotUrl}" style="height: 160px;max-width: 320px;"/></td>
                        <td>${parkingZone.intro}</td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
            <ul class="pagination"></ul>
        </div>
    </form>
</div>
</body>
<jsp:include page="../../body/javascript-page.jsp" flush="true"/>
<script type="application/javascript">
    function toEdit(){
        var id = getAllCheck("form");
        if(id.length != 1){
            layer.msg("请选择一条数据",{icon:0,timeout:1000});
        } else {
            LAYER.addLayerWithSize("layer_parkingZoneEdit","修改分区","/car/parkingZone/edit?id="+id,"800px","520px");
        }
    }

    function  deleteAll(){
        var  ids=getAllCheck("form");
        if(ids.length <=0){
            layer.msg("请选择删除的数据",{icon:0,timeout:1000});
        }else{
            layer.confirm("确定要删除" + ids.length + "条数据？",{title:"提示",btn:["确定","取消"]},function () {
                $.ajax({
                    type:"POST",
                    url:"/car/parkingZone/deleteDataByIds",
                    dataType:"json",
                    data:{"ids":ids.join(",")},
                    success:function (data) {
                        if(data.success){
                            layer.msg("删除成功",{icon:1,timeout:1000});
                            reloadPage();
                        } else {
                            layer.msg("删除失败",{icon:2,timeout:1000});
                        }
                    }
                    });
            });

        }

     }
</script>
</html>
